package com.yxyu.tree;

import lombok.Data;

/**
 * 一个普通的二叉树
 * @author yl
 */
@Data
public class Tree<V> {

    /**
     * value
     */
    private V v;
    private Tree left;
    private Tree right;

    public Tree(V v) {
        this.v = v;
    }

    public Tree<V> setLeft(V left) {
        return this.setLeft(new Tree(left));
    }

    public Tree<V> setRight(V right) {
        return setRight(new Tree(right));
    }

    public Tree<V> setLeft(Tree<V> left) {
        this.left = left;
        return this;
    }

    public Tree<V> setRight(Tree<V> right) {
        this.right = right;
        return this;
    }

    @java.lang.Override
    public java.lang.String toString() {
        return "Tree{" +
                "v=" + v +
                '}';
    }
}
